<template>
  <div>
    <a-spin :spinning='loading' tip=" 正在加载数据，请耐心等待">
    <a-table
      ref='table'
      size='middle'
      bordered
      :rowKey="record => record.qxId"
      childrenColumnName='childrenColumnName'
      :columns='columns'
      :dataSource='dataSource'
      :pagination="false"
    >
    <span slot='action' slot-scope='text, record,index'>
          <a :class="{active: false}" @click='handleEditStep2(record,index)'>查看详情</a>
<!--          <a-divider type='vertical' />-->
<!--          <a @click='handleDel(record.qxId)'> 确认 </a>-->
    </span>
    </a-table>
    </a-spin>
    <KeyStatisticsQxModal ref="keyStatisticsQxModal" v-on:getSortPolluteQx="getSortPolluteQx"></KeyStatisticsQxModal>
  </div>
</template>

<script>
import EpaSortService from '@/myService/EpaSortService'
import KeyStatisticsQxModal from '@views/epa/epa-statistics/Modal/KeyStatisticsQxModal'

export default {
  name: 'Step2',
  components:{
    KeyStatisticsQxModal
  },
  props: ['startDate','endDate'],
  data() {
    return {
      loading:true,
      currentIndex:[],
      dataSource: [],
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: (text, row, index) => 1 + index
        },
        {
          title: '污染大类',
          dataIndex: 'polluteName',
          align: 'center'
        },
        {
          title: '去向单位',
          dataIndex: 'qx',
          align: 'center'
        },
        {
          title: '工单数',
          dataIndex: 'qxNum',
          align: 'center'
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ]
    }
  },
  created() {
  },
  methods:{
    getSortPolluteQx(){
      console.log("刷新去向单位模板")
      EpaSortService.selectSortPolluteQxNum({startDate:this.startDate,endDate:this.endDate}).then((res)=>{
        this.dataSource=res.result
      }).finally(
        ()=>{
          this.loading=false
        }
      )
    },
    handleEditStep2(record,index){
      console.log("dddddddddddddddd")
      console.log(record)
      console.log(this.startDate)
      console.log(this.endDate)
      this.$refs.keyStatisticsQxModal.open(record,this.startDate,this.endDate)
      this.currentIndex[index] = record.qxNum
      this.getSortPolluteQx()
    }
  }
}
</script>

<style scoped>
  .active {
    color: red;
  }
</style>